package ru.nsu.expertsystem.chucknorris;

public class Strike extends AbstractWhoWhomPredicate implements Predicate {
	private StrikeType strikeType;
	
	public Strike() {
		
	}
	
	public Strike(Person who, Person whom, StrikeType strikeType) {
		super(who, whom);
		this.strikeType = strikeType;
	}


	/**
	 * @return the strikeType
	 */
	public StrikeType getStrikeType() {
		return strikeType;
	}


	/**
	 * @param strikeType the strikeType to set
	 */
	public void setStrikeType(StrikeType strikeType) {
		this.strikeType = strikeType;
	}

	@Override
	public String toString() {
		return String.format(IMessages.StrkeMessage, getWho(), getWhom(), strikeType);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((strikeType == null) ? 0 : strikeType.hashCode());
		result = prime * result + ((getWho() == null) ? 0 : getWho().hashCode());
		result = prime * result + ((getWhom() == null) ? 0 : getWhom().hashCode());
		return result;
	}


	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(java.lang.Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Strike other = (Strike) obj;
		if (strikeType != other.strikeType)
			return false;
		if (getWho() != null) {
			if (other.getWho() != null)
				return false;
		} else if (!getWho().equals(other.getWho()))
			return false;
		if (getWhom() == null) {
			if (other.getWhom() != null)
				return false;
		} else if (!getWhom().equals(other.getWhom()))
			return false;
		return true;
	}
	
}
